package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.task.Task;
import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.ExhibitionDetailsEntity;
import com.zw.yzk.kabu.data.network.service.ExhibitionDetailsService;
import com.zw.yzk.kabu.data.network.task.ExhibitionDetailsTask;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2016/12/24.
 */

public class ExhibitionDetailsRepository extends CommonRepository {

    @Inject
    public ExhibitionDetailsRepository() {

    }

    @Override
    protected Observable connectServer(Task task) {
        ExhibitionDetailsService service = ServiceGenerator.createService(ExhibitionDetailsService.class);
        ExhibitionDetailsTask exhibitionDetailsTask = (ExhibitionDetailsTask) task;

        return service.getExhibitionDetails(exhibitionDetailsTask.exhibitionId, exhibitionDetailsTask.userId, exhibitionDetailsTask.accessToken);
    }

    @Override
    protected Func1<ExhibitionDetailsEntity, Observable> getServerData() {
        return new Func1<ExhibitionDetailsEntity, Observable>() {
            @Override
            public Observable call(ExhibitionDetailsEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
